home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / misc / DigitalLibrary.lha / DigitalLibrary / DigitalLib.asm < prev    next >
Encoding:
Assembly Source File  |  2000-10-07  |  6.5 KB  |  345 lines

  1.  ; ##########################################################################
  2.  ; ####                                                                  ####
  3.  ; ####     DigitalLibrary - An Amiga library for memory allocation      ####
  4.  ; ####    =========================================================     ####
  5.  ; ####                                                                  ####
  6.  ; #### DigitalLib.asm                                                   ####
  7.  ; ####                                                                  ####
  8.  ; #### Version 1.00  --  October 06, 2000                               ####
  9.  ; ####                                                                  ####
  10.  ; #### Copyright (C) 1992  Thomas Dreibholz                             ####
  11.  ; ####                     Molbachweg 7                                 ####
  12.  ; ####                     51674 Wiehl/Germany                          ####
  13.  ; ####                     EMail: Dreibholz@bigfoot.com                 ####
  14.  ; ####                     WWW:   http://www.bigfoot.com/~dreibholz     ####
  15.  ; ####                                                                  ####
  16.  ; ##########################################################################
  17.  
  18.  ; ***************************************************************************
  19.  ; *                                                                         *
  20.  ; *   This program is free software; you can redistribute it and/or modify  *
  21.  ; *   it under the terms of the GNU General Public License as published by  *
  22.  ; *   the Free Software Foundation; either version 2 of the License, or     *
  23.  ; *   (at your option) any later version.                                   *
  24.  ; *                                                                         *
  25.  ; ***************************************************************************
  26.  
  27.  include "exec/types.i"
  28.  include "exec/initializers.i"
  29.  include "exec/libraries.i"
  30.  include "exec/lists.i"
  31.  include "exec/nodes.i"
  32.  include "exec/resident.i"
  33.  include "libraries/dos.i"
  34.  include "exec/alerts.i"
  35.  
  36. CALLSYS  MACRO
  37.  jsr _LVO%1(a6)
  38.  endm
  39. XLIB  MACRO
  40.  xref _LVO%1
  41.  endm
  42.  
  43.  STRUCTURE DigitalLib,LIB_SIZE
  44.   ULONG dl_SysLib
  45.   ULONG dl_DosLib
  46.   ULONG dl_SegList
  47.   UBYTE dl_Flags
  48.   UBYTE dl_Pad
  49.  LABEL DigitalLib_SIZEOF
  50.  
  51.  XLIB OpenLibrary
  52.  XLIB CloseLibrary
  53.  XLIB FreeMem
  54.  XLIB Remove
  55.  XLIB Alert
  56.  XREF _AllocChipMem
  57.  XREF _AllocFastMem
  58.  XREF _AllocMemory
  59.  XREF _FreeMemory
  60.  XREF _AllocRChipMem
  61.  XREF _AllocRFastMem
  62.  XREF _AllocRMemory
  63.  XREF _FreeRMemory
  64.  XREF _CreateMemHeader
  65.  XREF _DeleteMemHeader
  66.  XREF _AllocLMemory
  67.  XREF _FreeLMemory
  68.  XREF _AvailChipMem
  69.  XREF _AvailFastMem
  70.  XREF _AvailMemory
  71.  XREF _AvailLMemory
  72.  XREF _BackupRList
  73.  XREF _RestoreRList
  74.  XREF _AllocDRemember
  75.  XREF _AllocDMemory
  76.  XREF _AllocAddress
  77.  XREF _AllocRAddress
  78.  
  79. Version   equ 38
  80. Revision  equ 0
  81. Pri       equ 75
  82.  
  83. Start:
  84.  moveq #0,d0
  85.  rts
  86.  
  87. Resident:
  88.  dc.w RTC_MATCHWORD
  89.  dc.l Resident
  90.  dc.l EndCode
  91.  dc.b RTF_AUTOINIT
  92.  dc.b Version
  93.  dc.b NT_LIBRARY
  94.  dc.b Pri
  95.  dc.l LibName
  96.  dc.l idString
  97.  dc.l Init
  98.  
  99. LibName:  dc.b 'digital.library',0
  100. idString: dc.b 'digital.library 38.0 (21 Apr 92)',13,10,0
  101. DosName:  dc.b 'dos.library',0
  102.  ds.w 0
  103.  
  104. EndCode:
  105.  
  106. Init:
  107.  dc.l DigitalLib_SIZEOF
  108.  dc.l FuncTable
  109.  dc.l DataTable
  110.  dc.l InitRoutine
  111.  
  112. FuncTable:
  113.  dc.l Open
  114.  dc.l Close
  115.  dc.l Expunge
  116.  dc.l Null
  117.  
  118.  dc.l AllocChipMem
  119.  dc.l AllocFastMem
  120.  dc.l AllocMemory
  121.  dc.l FreeMemory
  122.  
  123.  dc.l AllocRChipMem
  124.  dc.l AllocRFastMem
  125.  dc.l AllocRMemory
  126.  dc.l FreeRMemory
  127.  
  128.  dc.l CreateMemHeader
  129.  dc.l DeleteMemHeader
  130.  dc.l AllocLMemory
  131.  dc.l FreeLMemory
  132.  
  133.  dc.l AvailChipMem
  134.  dc.l AvailFastMem
  135.  dc.l AvailMemory
  136.  dc.l AvailLMemory
  137.  
  138.  dc.l BackupRList
  139.  dc.l RestoreRList
  140.  
  141.  dc.l AllocSpecialMem
  142.  dc.l AllocRSpecialMem
  143.  dc.l AllocAddress
  144.  dc.l AllocRAddress
  145.  
  146.  dc.l -1
  147.  
  148. DataTable:
  149.  INITBYTE LH_TYPE,NT_LIBRARY
  150.  INITLONG LN_NAME,LibName
  151.  INITBYTE LIB_FLAGS,LIBF_SUMUSED!LIBF_CHANGED
  152.  INITWORD LIB_VERSION,Version
  153.  INITWORD LIB_REVISION,Revision
  154.  INITLONG LIB_IDSTRING,idString
  155.  dc.l 0
  156.  
  157. InitRoutine:
  158.  move.l a5,-(a7)
  159.  move.l d0,a5
  160.  move.l a6,dl_SysLib(a5)
  161.  move.l a0,dl_SegList(a5)
  162.  lea DosName(pc),a1
  163.  moveq.l #0,d0
  164.  CALLSYS OpenLibrary
  165.  move.l d0,dl_DosLib(a5)
  166.  bne.s 1$
  167.  ALERT AG_OpenLib!AO_DOSLib
  168. 1$:
  169.  move.l a5,d0
  170.  move.l (a7)+,a5
  171.  rts
  172.  
  173. Open:
  174.  addq.w #1,LIB_OPENCNT(a6)
  175.  bclr #LIBB_DELEXP,dl_Flags(a6)
  176.  move.l a6,d0
  177.  rts
  178.  
  179. Close:
  180.  clr.l d0
  181.  subq.w #1,LIB_OPENCNT(a6)
  182.  bne.s 1$
  183.  btst #LIBB_DELEXP,dl_Flags(a5)
  184.  beq.s 1$
  185.  bsr Expunge
  186. 1$:
  187.  rts
  188.  
  189. Expunge:
  190.  movem.l d2/a5-a6,-(a7)
  191.  move.l a6,a5
  192.  move.l dl_SysLib(a5),a6
  193.  tst.w LIB_OPENCNT(a5)
  194.  beq.s 1$
  195.  bset #LIBB_DELEXP,dl_Flags(a5)
  196.  clr.l d0
  197.  bra.s Expunge_end
  198. 1$:
  199.  move.l dl_SegList(a5),d2
  200.  move.l a5,a1
  201.  CALLSYS Remove
  202.  move.l dl_DosLib(a5),a1
  203.  CALLSYS CloseLibrary
  204.  clr.l d0
  205.  move.l a5,a1
  206.  move.w LIB_NEGSIZE(a5),d0
  207.  sub.l d0,a1
  208.  add.w LIB_POSSIZE(a5),d0
  209.  CALLSYS FreeMem
  210.  move.l d2,d0
  211. Expunge_end:
  212.  movem.l (a7)+,d2/a5-a6
  213.  rts
  214. Null:
  215.  moveq #0,d0
  216.  rts
  217. AllocChipMem:
  218.  move.l d0,-(sp)
  219.  jsr _AllocChipMem
  220.  add.w #4,sp
  221.  move.l d0,d1
  222.  rts
  223. AllocFastMem:
  224.  move.l d0,-(sp)
  225.  jsr _AllocFastMem
  226.  add.w #4,sp
  227.  move.l d0,d1
  228.  rts
  229. AllocMemory:
  230.  move.l d0,-(sp)
  231.  jsr _AllocMemory
  232.  add.w #4,sp
  233.  move.l d0,d1
  234.  rts
  235. FreeMemory:
  236.  move.l a0,-(sp)
  237.  jsr _FreeMemory
  238.  add.w #4,sp
  239.  rts
  240. AllocRChipMem:
  241.  move.l d0,-(sp)
  242.  jsr _AllocRChipMem
  243.  add.w #4,sp
  244.  move.l d0,d1
  245.  rts
  246. AllocRFastMem:
  247.  move.l d0,-(sp)
  248.  jsr _AllocRFastMem
  249.  add.w #4,sp
  250.  move.l d0,d1
  251.  rts
  252. AllocRMemory:
  253.  move.l d0,-(sp)
  254.  jsr _AllocRMemory
  255.  add.w #4,sp
  256.  move.l d0,d1
  257.  rts
  258. FreeRMemory:
  259.  jsr _FreeRMemory
  260.  rts
  261. CreateMemHeader:
  262.  move.l a1,-(sp)
  263.  move.l a0,-(sp)
  264.  move.l d2,-(sp)
  265.  move.l d1,-(sp)
  266.  move.l d0,-(sp)
  267.  jsr _CreateMemHeader
  268.  add.w #20,sp
  269.  move.l d0,d1
  270.  rts
  271. DeleteMemHeader:
  272.  move.l a0,-(sp)
  273.  jsr _DeleteMemHeader
  274.  add.w #4,sp
  275.  rts
  276. AllocLMemory:
  277.  move.l d0,-(sp)
  278.  move.l a0,-(sp)
  279.  jsr _AllocLMemory
  280.  add.w #8,sp
  281.  move.l d0,d1
  282.  rts
  283. FreeLMemory:
  284.  move.l d0,-(sp)
  285.  move.l a0,-(sp)
  286.  jsr _FreeLMemory
  287.  add.w #8,sp
  288.  rts
  289. AvailChipMem:
  290.  jsr _AvailChipMem
  291.  move.l d0,d1
  292.  rts
  293. AvailFastMem:
  294.  jsr _AvailFastMem
  295.  move.l d0,d1
  296.  rts
  297. AvailMemory:
  298.  jsr _AvailMemory
  299.  move.l d0,d1
  300.  rts
  301. AvailLMemory:
  302.  move.l a0,-(sp)
  303.  jsr _AvailLMemory
  304.  add.w #4,sp
  305.  move.l d0,d1
  306.  rts
  307. BackupRList:
  308.  jsr _BackupRList
  309.  move.l d0,d1
  310.  rts
  311. RestoreRList:
  312.  move.l a0,-(sp)
  313.  jsr _RestoreRList
  314.  add.w #4,sp
  315.  rts
  316. AllocSpecialMem:
  317.  move.l d1,-(sp)
  318.  move.l d0,-(sp)
  319.  jsr _AllocDMemory
  320.  add.w #8,sp
  321.  move.l d0,d1
  322.  rts
  323. AllocRSpecialMem:
  324.  move.l d1,-(sp)
  325.  move.l d0,-(sp)
  326.  jsr _AllocDRemember
  327.  add.w #8,sp
  328.  move.l d0,d1
  329.  rts
  330. AllocAddress:
  331.  move.l d1,-(sp)
  332.  move.l d0,-(sp)
  333.  jsr _AllocAddress
  334.  add.w #8,sp
  335.  move.l d0,d1
  336.  rts
  337. AllocRAddress:
  338.  move.l d1,-(sp)
  339.  move.l d0,-(sp)
  340.  jsr _AllocRAddress
  341.  add.w #8,sp
  342.  move.l d0,d1
  343.  rts
  344.  END
  345.